<script lang="ts" setup>

import reqApis from "../../req/reqApis.js";
import {showNotify} from 'vant';
import {ref } from 'vue';
import headerUtil from "../base/common/headerUtil.vue";

const recommendRef = ref();

showNotify({ type: 'primary', message: '1232132132' });

const isLoading = ref(false); 

const headerObj =  {
        showType: 4,
        isRed: false,
      }
 
    reqApis.initPageApi({}).then(res => {
                    // console.log(res);
                console.log(res)
            }).catch(err => {
                console.log(err)
            })
// aa();
function handleScroll(event){
    const { scrollTop, scrollHeight,scrollWidth, clientHeight, scrollLeft, offsetWidth } = event.target;
    const isScrolledToBottom = scrollHeight - (scrollTop + clientHeight) <= 1; // 1像素的误差
    const isScrolledToRight = scrollWidth - (scrollLeft + offsetWidth) <= 1; // 1像素的误差
    
    if (isScrolledToBottom && isScrolledToRight) {
        if (!isLoading.value) {
            isLoading.value = true;
            setTimeout(() => {
                isLoading.value = false;
                recommendRef.value.loadFeedItem()
            }, 1000); // 模拟加载时间
        }
    }
}

  



</script>

<style lang="scss" scoped>

h1 {
    color: var(--el-text-color-regular);
}
html.dark {
    h1 {
        color: var(--el-text-color-regular);
    }
}
.index_wrap{
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f4f4f4;
    .abs {
        position: absolute;
        left: 0;
        bottom: 0;
    }
}
.test {
    font-size: .16rem;
}
</style>
<template>
    <div class="index_wrap" @scroll="handleScroll">
        <headerUtil :obj="headerObj" @myClick="headerFn"></headerUtil>
    </div>
</template>